package edu.scs.ubbcluj.model;

public class ForeignKey extends Attribute {
    
    private Table refTable;
    private Attribute refAttr;

    public ForeignKey(Attribute attr, Table table, boolean isUnique) {
        super(attr.getName(), attr.getTip(), attr.getLength(), attr.isIsNull(), isUnique);
        this.refTable = table;
        this.refAttr = attr;
    }
    
    public ForeignKey(Attribute attr, Table table) {
        super(attr.getName(), attr.getTip(), attr.getLength(), attr.isIsNull(), attr.isUnique());
        this.refTable = table;
        this.refAttr = attr;
    }
    
    public Table getTable() {
        return refTable;
    }
    
    public Attribute getRefAttr() {
        return refAttr;
    }

    public void setTable(Table table) {
        this.refTable = table;
    }
    
    @Override
    public String toString() {
        return super.toString() + " (foreign key)";
    }
    
}